package com.demoworld;

import org.junit.Assert;
import org.junit.Test;

/**
 * Created by francis on 2017/7/7.
 */
public class JSingleLinkedListTest {
    @Test
    public void testAdd1() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);

        Assert.assertEquals(3, list.length);
    }

    @Test
    public void testExist1() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);


        Assert.assertEquals(true, list.exist(13));
    }

    @Test
    public void testExist2() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);

        Assert.assertEquals(false, list.exist(110));
    }

    @Test
    public void testRemove1() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);


        Assert.assertEquals(true, list.remove(10));
    }

    @Test
    public void testRemove2() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);

        ;
        Assert.assertEquals(false, list.remove(100));
    }

    @Test
    public void testRemove3() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);

        list.remove(10);

        Assert.assertEquals(false, list.exist(10));
    }

    @Test
    public void testRemove4() {
        JSingleLinkedList list = new JSingleLinkedList();
        list.add(10);
        list.add(11);
        list.add(13);

        list.remove(13);

        Assert.assertEquals(false, list.exist(13));
    }

@Test
public void testReverse() {
    JSingleLinkedList list = new JSingleLinkedList();
    list.add(10);
    list.add(11);
    list.add(13);

    JLinkedListStackNode head = list.reverseAndReturnHead();

    Assert.assertEquals(13, head.value);
}
}
